from  django import forms

from demo.models import Classes, Label


class ArticleForm(forms.Form):
    title=forms.CharField(
        label='标题',
        max_length=30,
        min_length=2,
        error_messages=dict(min_length='长度小于2', max_length='长度大于30')

    )

    desc=forms.CharField(
        label="文章简介",
        max_length=100,
        min_length=10,
        error_messages=dict(min_length='长度小于10', max_length='长度大于100')
    )
    content=forms.CharField(
        label='内容',
        widget=forms.Textarea
    )
    cover=forms.FileField(
        label='封面图'
    )
    classes=forms.ModelChoiceField(
        label='分类',
        queryset=Classes.objects.all(),
        empty_label=None
    )
    label=forms.ModelMultipleChoiceField(
        label='标签',
        queryset=Label.objects.all()
    )